% write_basic_type_plain.pro

% intended for inclusion in module write_basic_term

:- style_check(-atom).          % allow long atoms


%------------------------------------------------------------------------------
% WRITE A BASIC TYPE IN AS types of term in plain text FORMAT
%------------------------------------------------------------------------------

%   write_basic_type_plain(+Term)
%
%   write plain text describing type of term
%   Term is a basic type represented as a typed prolog type
%
write_basic_type_plain(Term) :-
    basic_type_plain(Term).



basic_type_plain(X::T) :-
    X =.. [abstraction|Ps],
    !,
    findall(
        A,
        (
         member(P-_,Ps),
         with_output_to(atom(A), basic_type_plain(P))
        ),
        As
    ),
    concat_atom(As,', ',_S),     %FIXME: wot?
    %
    memberchk(_-M,Ps),
    abstraction_brackets(M, LeftBracket,RightBracket),
    format('~w ~w ~w', [LeftBracket,T,RightBracket]).

basic_type_plain(X::T) :-
    X =.. [tuple|Ps],
    !,
    findall(
        A,
        (
         member(P,Ps),
         with_output_to(atom(A), basic_type_plain(P))
        ),
        As
    ),
    concat_atom(As,',',_S),     %FIXME: wot?
    format('(~w)', [T]).

basic_type_plain(X::T) :-
    X =.. [_C|Ps],
    !,
    % constructor
    format(T),
    %
    (Ps == []
    ->  true
    ;
        findall(
            A,
            (
             member(P,Ps),
             with_output_to(atom(A), basic_type_plain(P))
            ),
            As
        ),
        concat_atom(As,',',S),
        format('~w', [S])
    ).
